package com.a3g.findnumber.entity;



import com.a3g.findnumber.R;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.util.Log;

public class MusicService extends Service {
	private static final String TAG = "MusicService";
	MediaPlayer bgMusic;
	
	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}
	
	@Override
	public void onCreate() {
		Log.d(TAG, "onCreate");
		// Release any resources from previous MediaPlayer
		if (bgMusic != null) {
			bgMusic.release();
		}
		bgMusic = MediaPlayer.create(this, R.raw.bg_music);
		bgMusic.setLooping(true);
	}

	@Override
	public void onDestroy() {
		Log.d(TAG, "onDestroy");
		// Release any resources from previous MediaPlayer
		if (bgMusic != null) {
			bgMusic.stop();
			bgMusic.release();
		}
		
	}
	
	@Override
	public void onStart(Intent intent, int startid) {
		Log.d(TAG, "onStart");
		bgMusic.start();
	}
}
